package cn.mesmile.flow.modules.processdefinition.controller;

import cn.mesmile.flow.modules.processdefinition.model.dto.ProcessDeployDTO;
import cn.mesmile.flow.modules.processdefinition.model.vo.ProcessDeployVO;
import cn.mesmile.flow.modules.processdefinition.service.ProcessDefinitionService;
import lombok.AllArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * @author zb
 * @date 2020/12/7 13:01
 * @Description
 */
@AllArgsConstructor
@RequestMapping("/api/v1/definition")
@RestController
public class ProcessDefinitionController {


    private final ProcessDefinitionService processDefinitionService;

    private final RestTemplate restTemplate;


    /**
     * DTO：前端给后端传递的数据
     * VO：后端给前端传递的数据
     * @return
     */
    @PostMapping("/deploy")
    public ProcessDeployVO deploy(@RequestBody ProcessDeployDTO processDeployDTO) {
        processDefinitionService.deploy(processDeployDTO);
        return null;
    }

    @GetMapping(value = "/get",produces= MediaType.APPLICATION_JSON_VALUE)
    public void get() {
        processDefinitionService.get();
    }

    @GetMapping("/process")
    public void test(){
        String path = "http://mt2.google.com/vt/lyrs=y@167000000&hl=zh-CN&gl=cn&x=0&y=6&z=4";
//        path = "http://www.baidu.com";
        Object forObject = restTemplate.getForObject(path, byte[].class);
        System.out.println(forObject);
    }


}
